import { request } from "@/utils/service"
import type * as Scene from "./types/scene"
import { AxiosResponse } from "axios"
import { TabTypeEnum } from "@/constants/other-keys"

/** 增 */
export function createSceneDataApi(data: FormData) {
  return request<Scene.SceneSaveResponseData>({
    headers: {
      "Content-Type": "multipart/form-data"
    },
    url: "/toksim/resource/game/add",
    method: "post",
    data
  })
}

/** 删 */
export function deleteSceneDataApi(id: string) {
  return request({
    url: `/toksim/resource/game/delete/${id}`,
    method: "post"
  })
}

/** 改 */
export function updateSceneDataApi(data: FormData) {
  return request<Scene.SceneSaveResponseData>({
    headers: {
      "Content-Type": "multipart/form-data"
    },
    url: "/toksim/resource/game/edit",
    method: "post",
    data
  })
}

/** 查 */
export function getSceneDataApi(params: Scene.PageTableRequestData) {
  return request<Scene.SearchSceneTableResponseData>({
    url: "/toksim/resource/game/search",
    method: "post",
    data: params
  })
}

/** 查 */
export function getSceneListApi(type: TabTypeEnum) {
  return request<Scene.SceneListResponseData>({
    url: `/toksim/resource/game/${type}/list`,
    method: "get"
  })
}

/** 根据id查询场景库信息 */
export function getSceneInfoApi(id: string) {
  return request<Scene.SceneInfoResponseData>({
    url: `/toksim/resource/game/get/${id}`,
    method: "get"
  })
}
/** 获取仿真场景类型 */
export function getSceneTypeOptionsApi() {
  return request<ApiResponseData<string[]>>({
    url: `/toksim/resource/game/type/get`,
    method: "get"
  })
}

/** 下载仿真场景场景 */
export function downloadSceneApi(id: string) {
  return request<AxiosResponse>({
    headers: {
      "Content-Type": "application/octet-stream"
    },
    responseType: "blob",
    url: `/toksim/resource/game/download/${id}`,
    method: "get"
  })
}
